package com.cxria.pattern.commandAndResponsibilityChain

abstract class Command {

    abstract String execute(CommandVO vo)

    protected final List<? extends CommandName> buildChain(Class<? extends CommandName> abstractClass){
        List<Class> classes = ClassUtils.getSonClass(abstractClass)
        List<CommandName> commandNameList = new ArrayList<>()
        for(c in classes){
            CommandName commandName = Class.forName(c.name).newInstance()
            if(commandNameList.size() > 0){
                commandNameList.get(commandNameList.size()-1).setNext(commandName)
            }
            commandNameList.add(commandName)
        }
        commandNameList
    }

}
